util: check RegExp is function#475
Closed
yosuke-furukawa wants to merge 1 commit intonodejs:v1.xfrom
yosuke-furukawa:fix/check_RegExp_isFunction
Closed
util: check RegExp is function#475yosuke-furukawa wants to merge 1 commit intonodejs:v1.xfrom yosuke-furukawa:fix/check_RegExp_isFunction
yosuke-furukawa wants to merge 1 commit intonodejs:v1.xfrom
yosuke-furukawa:fix/check_RegExp_isFunction
Conversation
Contributor
|
Throwing random check doesn't seem like a good idea. For some reason v8 does this: https://github.com/iojs/io.js/blob/v1.x/deps/v8/benchmarks/regexp.js#L40 Wrapping code in IIFE doesn't work because benchmark relies on globals, so the solution is to run code in a new context. |
Member
Author
|
OK. Thank you for your suggestion. I will try to separate the RegExp benchmark test. |
bnoordhuis
added a commit
to bnoordhuis/io.js
that referenced
this pull request
Jan 18, 2015
deps/v8/benchmarks/regexp.js clobbers the RegExp global, breaking
util.format() and console.log(). Unclobber it to keep the other
benchmarks working.
Fixes the following error when running benchmark/misc/v8-bench.js:
$ out/Release/iojs benchmark/misc/v8-bench.js
util.js:84
if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
^
TypeError: object is not a function
at Object.exports.debuglog (util.js:84:9)
at timers.js:12:29
at NativeModule.compile (node.js:800:5)
at NativeModule.require (node.js:769:18)
at net.js:5:14
at NativeModule.compile (node.js:800:5)
at NativeModule.require (node.js:769:18)
at tty.js:4:11
at NativeModule.compile (node.js:800:5)
at Function.NativeModule.require (node.js:769:18)
This could alternatively be addressed by caching the RegExp global
in lib/util.js. That's not a bad approach and I considered it but
doing it for just RegExp and not other globals would be half-baked.
Maybe the more thorough approach where we cache all globals at
start-up is something for a follow-up pull request.
Fixes: nodejs#475
bnoordhuis
added a commit
that referenced
this pull request
Jan 18, 2015
deps/v8/benchmarks/regexp.js clobbers the RegExp global, breaking
util.format() and console.log(). Unclobber it to keep the other
benchmarks working.
Fixes the following error when running benchmark/misc/v8-bench.js:
$ out/Release/iojs benchmark/misc/v8-bench.js
util.js:84
if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
^
TypeError: object is not a function
at Object.exports.debuglog (util.js:84:9)
at timers.js:12:29
at NativeModule.compile (node.js:800:5)
at NativeModule.require (node.js:769:18)
at net.js:5:14
at NativeModule.compile (node.js:800:5)
at NativeModule.require (node.js:769:18)
at tty.js:4:11
at NativeModule.compile (node.js:800:5)
at Function.NativeModule.require (node.js:769:18)
This could alternatively be addressed by caching the RegExp global
in lib/util.js. That's not a bad approach and I considered it but
doing it for just RegExp and not other globals would be half-baked.
Maybe the more thorough approach where we cache all globals at
start-up is something for a follow-up pull request.
Fixes: #475
PR-URL: #489
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Yosuke Furukawa <yosuke.furukawa@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I am checking benchmark tests.
When I execute the following tests, I got the errors.
I don't understand why this error is occurred, but I guess
RegExpis not function in vm context.So I just checked RegExp is function, the benchmark test works fine.